package demo.code;

import java.io.IOException;

import org.apache.log4j.FileAppender;
import org.apache.log4j.Level;
import org.apache.log4j.Logger;
import org.apache.log4j.SimpleLayout;

/**
 * 通过代码配置log4j
 * append: fileAppender
 * layout: simpleLayout
 * @author hnnin
 *
 */
public class SimpleAndFile {
	static Logger logger = Logger.getLogger(SimpleAndFile.class);
	public static void main(String args[]) throws IOException {
		SimpleLayout simpleLayout=new SimpleLayout();
		FileAppender fileAppender=null;
		
		fileAppender=new FileAppender(simpleLayout, "output_by_code/SimpleAndFileOutput.txt");
		logger.addAppender(fileAppender);
		logger.setLevel((Level) Level.DEBUG);

		logger.debug("Here is some DEBUG");

		logger.info("Here is some INFO");

		logger.warn("Here is some WARN");

		logger.error("Here is some ERROR");

		logger.fatal("Here is some FATAL");
		
	}

}
